package com.yanqu.road.logic.sort;

import com.yanqu.road.entity.rank.UnionActivityRank;

import java.util.Comparator;

public class UnionWarActivityRankSort implements Comparator<UnionActivityRank> {

    @Override
    public int compare(UnionActivityRank o1, UnionActivityRank o2) {
        int result = o2.getValue().compareTo(o1.getValue());
        if (result != 0) {
            return result;
        }
        result = o2.getUnionBaseInfo().getTotalEarnSpeed().compareTo(o1.getUnionBaseInfo().getTotalEarnSpeed());
        if (result != 0) {
            return result;
        }
        long time = o1.getLastUpdateTime() - o2.getLastUpdateTime();
        result = time > 0 ? 1 : (time == 0 ? 0 : -1);
        return result;

    }
}
